#!/bin/bash

url=${1:-http://iupr1.cs.uni-kl.de/~tmb/ocropus-models/}

if test -d ../ocrolib; then true; else
    echo "must be run from 'models' subdirectory of the ocropy repository"
    exit 1
fi

python -c '
import sys
sys.path = [".."]+sys.path
from ocrolib import default
print default.model+".bz2"
print default.space+".bz2"
print default.ngraphs+".bz2"
' |
while read f; do
    echo
    echo === $f
    echo
    if test -f $(basename $f .bz2); then 
        echo "already downloaded"
        continue
    else
        wget -nd ${url}/$f
        bunzip2 $f
    fi
done
echo
